#ifndef _WRITTEN_CHARACTER_H
#define _WRITTEN_CHARACTER_H

class SubStrokeDescriptor
{
public:
    SubStrokeDescriptor(double direction, double length)
    {
        this->direction = direction;
        this->length = length;
    }
    double getDirection() { return this->direction }
	double getLength() { return this->length; }
    
private:
    double direction;
    double length;
}

//todo
class WrittenPoint : public Point
{
public:
    WrittenPoint();
    int getSubStrokeIndex() { return this->subStrokeIndex; }
    void setSubStrokeIndex(int subStrokeIndex) { this->subStrokeIndex = subStrokeIndex; }
    bool isPivot() { return this->isPivot; }
    void setIsPivot(bool isPivot) { this->isPivot = isPivot; }
    
private:
    int subStrokeIndex;
    bool isPivot;
    double getDistanceNormalized(WrittenPoint *comparePoint);
    double getDirection(WrittenPoint *comparePoint);
}
    
class WrittenStroke
{
public:
    WrittenStroke();
    ~WrittenStroke();
    QList* getPointList() { return this->pointList; }
    boolean isAnalyzed() { return this->isAnalyzed; }
    void addPoint(WrittenPoint point);
    QList* getSubStrokes();
    
private:
    void analyzeAndMark();
    QList *pointList;
    bool isAnalyzed;
    // Defines the minimum length of a SubStroke segment.
    // If a two pivot points are within this length, the first of the pivots will be unmarked as a pivot.
    static final private double MIN_SEGMENT_LENGTH = 12.5;
    // Used to find abrupt corners in a stroke that delimit two SubStrokes.
    static final private double MAX_LOCAL_LENGTH_RATIO = 1.1;
    // Used to find a gradual transition between one SubStroke and another at a curve.
    static final private double MAX_RUNNING_LENGTH_RATIO = 1.09;
}


class WrittenCharacter
{
public:
    WrittenCharacter();
    ~WrittenCharacter();
    QList getStrokeList();
	void addStroke(WrittenStroke stroke);
	void clear();
	void resetEdges();
	void analyzeAndMark();
	CharacterDescriptor buildCharacterDescriptor();
    
private:
    // Edges to keep track of the coordinates of the bounding box of the character.
	// Used to normalize lengths so that a character can be written in any size as long as proportional.
	double leftX;
	double rightX;
	double topY;
	double bottomY;
    // List of WrittenStrokes.
	QList *strokeList;
}

#endif